/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import { AppJson } from '../../../../src/options/configure/app-json-options';

import { BaseModifier } from './base-modifier';
import path = require('path');
import AppOptObj = AppJson.AppOptObj;

export class AppJsonModifier extends BaseModifier {
  protected jsonObject!: AppOptObj;

  constructor(cwd: string) {
    super(path.resolve(cwd, 'AppScope/app.json5'));
  }

  public setBundleName(bundleName: string): AppJsonModifier {
    this.jsonObject.app.bundleName = bundleName;
    return this;
  }

  public updateAttribute(attribute: string, value: unknown): AppJsonModifier {
    this.jsonObject.app[attribute] = value;
    return this;
  }
}
